import _ from 'lodash';

import { Driver } from './driver';
import { AtLeastOne } from '$common';
import { DriverManager } from './driverManager';
export class DriverService {

  private static driverRepo: DriverManager = DriverManager.Instance;

  static canConcurrent(driverName: string): boolean {
    return this.getByName(driverName).canConcurrent;
  }

  static getMaxConcurrent(driverName: string): number {
    return this.getByName(driverName).maxConcurrent;
  }

  static getByName(driverName: string): Driver {
    return this.driverRepo.getDriver(driverName);
  }

  static getDriverNames() {
    return Object.keys(this.driverRepo.getDrivers());
  }

  static getAll() {
    return Object.values(this.driverRepo.getDrivers());
  }

  static updateDriverBySelective(driverName: string, updatedAttributes: AtLeastOne<Omit<Driver, 'driverName'>>) {
    this.driverRepo.updateDriverBySelective(driverName, updatedAttributes);
  }
}